><

About relative and absolute length units



The format of a length value is an optional plus or minus sign (+ is the default), immediately followed by a number (with or without a decimal point) immediately followed by a unit identifier such as em, ex, or, pc. Some properties allow negative length units, but this may complicate the formatting and there may be browser-specific limitations.

There are two types of length units: relative and absolute. Relative units specify a length relative to another length property. Style sheets that use relative units will scale more easily from one output medium to another (for example, from a computer display to a laser printer).

Relative units may also reduce the differences in font size that occur when a page is viewed on different platforms. (See About font sizes across platforms.)

The following relative units are supported:

em
Height of the element's font
ex
Height of the letter X
pixel
Pixels relative to the resolution of the drawing area--that is, the computer display

Absolute length units are only useful when the physical properties of the output medium are known.

The following absolute length units are supported:

in
Inches, 1in. = 2.54 cm
cm
Centimeters
mm
Millimeters
pt
Points, 1pt = 1/72 in.
pc
Picas, 1pc = 12pt

Percentage units and keyword values (for example, xlarge) offer similar advantages in terms of scalability as relative units.


Using Cascading Style Sheets > About cascading style sheets > About relative and absolute length units